#include "CGame.h"

CGame::CGame()
{
};
CGame::~CGame()
{
};
void CGame::Generate(int sx,int sy,int ox,int oy) //0=up 1=down 2=left 3=right
{
	CEngine *e;
	int m[16][5];
	bool more;
	int i,j,k,l,x,y;
	int d1,d2;
	char b[255];
	CObject *o;
	e = (CEngine *)GetEngine();
	for(i=0;i<80;i++)//Boring stuff.
		for(j=0;j<25;j++)
			if(i==0||j==0||i==79||j==24)
			{
				e->m_Room->m_Map[i][j][0] = 0;
				e->m_Room->m_Map[i][j][1] = 0;
			};
	for(i=0;i<80;i++)
		for(j=0;j<25;j++)
		{
			e->m_Room->m_Map[i][j][0] = 0;
			e->m_Room->m_Map[i][j][1] = 0;
		};
	for(i=0;i<16;i++)//Initialize maze
		for(j=0;j<5;j++)
			m[i][j] = -1;
	m[rand()%(sx-1)][rand()%(sy-1)] = 0;
	while(1==1)//Generate a maze using hunt and kill.
	{
		more = false;
		i = rand()%sx;
		j = rand()%sy;
		if(j>0&&m[i][j]==-1&&m[i][j-1]!=-1)
			m[i][j] = 0;
		if(j<4&&m[i][j]==-1&&m[i][j+1]!=-1)
			m[i][j] = 1;
		if(i>0&&m[i][j]==-1&&m[i-1][j]!=-1)
			m[i][j] = 2;
		if(i<15&&m[i][j]==-1&&m[i+1][j]!=-1)
			m[i][j] = 3;
		for(i=0;i<sx;i++)
			for(j=0;j<sy;j++)
				if(m[i][j]==-1)
					more = true;
		/*for(i=0;i<sx;i++)//Display the maze to make sure there are no errors.
			for(j=0;j<sy;j++)
				switch(m[i][j])
				{
					case -1:
						mvaddch(j, i, 'X');
						break;
					case 0:
						mvaddch(j, i, '^');
						break;
					case 1:
						mvaddch(j, i, 'v');
						break;
					case 2:
						mvaddch(j, i, '<');
						break;
					case 3:
						mvaddch(j, i, '>');
						break;
				};
		refresh();*/
		
		if(!more)
			break;
	};
	//Pause for display
	for(i=0;i<sx;i++)//Render the maze onto the actual map in 5x5 rooms
		for(j=0;j<sy;j++)
		{
			d1 = rand()%100;
			d2 = rand()%100;
			for(k=0;k<5;k++)
				for(l=0;l<5;l++)
				{
				e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = 0;
				e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 0;
				if(k==0&&(i==0||(m[i][j]!=2&&m[i-1][j]!=3)))//Left wall or door
					e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 1;
				else if(k==0&&(d1<32||(i==1&&e->m_Room==(CRoom *)e->m_Rooms.Get(1))))//Decide if we should put a door
				{
					e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 1;
					if(l==4)//Place a hole in the wall for the door behind us.
					{
						x = ox+(i*5)+k;
						y = oy+(j*5)+l-(1+(rand()%3));
						e->m_Room->m_Map[x][y][0] = e->m_Room->m_Map[x][y][1] = 0;
						o = new CDoor(x,y);
						e->m_Room->m_Objects.Add(o);
					};
				};
				if(l==0&&(j==0||(m[i][j]!=0&&m[i][j-1]!=1)))//Top wall or door
					e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 1;
				else if(l==0&&(d2<51||(j==1&&e->m_Room==(CRoom *)e->m_Rooms.Get(1))))//Behold the golden ratio.
				{
					e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 1;
					if(k==4)
					{
						x = ox+(i*5)+k-(1+(rand()%3));
						y = oy+(j*5)+l;
						e->m_Room->m_Map[x][y][0] = e->m_Room->m_Map[x][y][1] = 0;
						o = new CDoor(x,y);
						e->m_Room->m_Objects.Add(o);
					};
				};
				
				if(k==4&&i==sx-1)//Exceptions at bottom and right wall of map
					e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 1;
				if(l==4&&j==sy-1)
					e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 1;
				if(k==0&&l==0)
					e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][0] = e->m_Room->m_Map[ox+(i*5)+k][oy+(j*5)+l][1] = 1;
			};
		};
	o = new CStairs(true);
	o->m_X = ox+(rand()%((sx-1)*5))+1;
	o->m_Y = oy+(rand()%((sy-1)*5))+1;
	while(e->m_Room->m_Map[o->m_X][o->m_Y][1]==1)
	{
		o->m_X = ox+(rand()%((sx-1)*5))+1;
		o->m_Y = oy+(rand()%((sy-1)*5))+1;
	};
	e->m_Room->m_Objects.Add(o);
	if(e->m_Room!=(CRoom *)e->m_Rooms.Get(0))//Is this the bottom floor?
	{
		o = new CStairs(false);
		o->m_X = ox+(rand()%((sx-1)*5))+1;
		o->m_Y = oy+(rand()%((sy-1)*5))+1;
		while(e->m_Room->m_Map[o->m_X][o->m_Y][1]==1)
		{
			o->m_X = ox+(rand()%((sx-1)*5))+1;
			o->m_Y = oy+(rand()%((sy-1)*5))+1;
		};
		e->m_Room->m_Objects.Add(o);
		
	};
	if(e->m_Room==(CRoom *)e->m_Rooms.Get(31))
	{
		o = new CLaundry();
		e->m_Room->m_Objects.Add(o);
	};
	if(e->m_Room==(CRoom *)e->m_Rooms.Get(1))
	{//Create first floor.
		i = ((rand()%4)*5)+(rand()%3);
		x = 20;
		y = 3+1+i;
		e->m_Room->m_Map[x][y][0] = e->m_Room->m_Map[x][y][1] = 0;
		o = new CDoor(x,y);
		e->m_Room->m_Objects.Add(o);//Backyard door.
		
		i = ((rand()%4)*5)+(rand()%3);
		x = 64;
		y = 4+i;
		e->m_Room->m_Map[x][y][0] = e->m_Room->m_Map[x][y][1] = 0;
		o = new CDoor(x,y);
		e->m_Room->m_Objects.Add(o);//Front door
		
		//Starting items:
		e->m_Groups.Spawn("Weapon 1",ox+1+(rand()%4),oy+1+(rand()%4));
		e->m_Groups.Spawn("Armor 1",ox+1+(rand()%4),oy+1+(rand()%4));
		e->m_Groups.Spawn("Food",ox+1+(rand()%4),oy+1+(rand()%4));
		e->m_Groups.Spawn("Food",ox+1+(rand()%4),oy+1+(rand()%4));
		e->m_Groups.Spawn("Food",ox+1+(rand()%4),oy+1+(rand()%4));
		e->m_Groups.Spawn("Food",ox+1+(rand()%4),oy+1+(rand()%4));
		e->m_Groups.Spawn("Water",ox+1+(rand()%4),oy+1+(rand()%4));
		e->m_Groups.Spawn("Water",ox+1+(rand()%4),oy+1+(rand()%4));
		
		
		for(i=0;i<20;i++)//Backyard grass
			for(j=0;j<24;j++)
				if(rand()%2==0)
					e->m_Room->m_Map[i][j][0] = 7;
		for(i=65;i<80;i++)//Front grass
			for(j=0;j<24;j++)
				if(rand()%2==0)
					e->m_Room->m_Map[i][j][0] = 7;
		for(i=5;i<20;i++)//Backyard fence
			for(j=3;j<23;j++)
			{
				if(i==5&&j==3)
					e->m_Room->m_Map[i][j][0] = 8;
				if(i==5&&j!=3)
					e->m_Room->m_Map[i][j][0] = 10;
				if(i!=5&&j==3)
					e->m_Room->m_Map[i][j][0] = 9;
				
				if((i==5&&j==22)||(i==19&&j==3)||(i==19&&j==22))
					e->m_Room->m_Map[i][j][0] = 8;
				
				if(i!=5&&j==22&&i!=19)
					e->m_Room->m_Map[i][j][0] = 9;
			};
		for(i=6;i<19;i++)//Garden
			for(j=4;j<7;j++)
				if(rand()%3!=0)
					e->m_Room->m_Map[i][j][0] = 11;
		x = 0;
		for(i=7;i<18;i++)//Trees
			for(j=9;j<21;j++)
				if(rand()%30==0)
				{
					e->m_Room->m_Map[i][j][0] = 12;
					e->m_Room->m_Map[i][j][1] = 1;
					x = 1;
				};
		if(x==0)
			for(i=7;i<18;i++)//If no trees were drawn, draw a garden.
				for(j=9;j<21;j++)
					if(rand()%4!=0)
						e->m_Room->m_Map[i][j][0] = 11;
					else
					{
						if(rand()%15==0)
						{
							e->m_Room->m_Map[i][j][0] = 12;
							e->m_Room->m_Map[i][j][1] = 1;
						};
					};
		
	};
	j = (10+(rand()%(30+(e->m_Rooms.GetLength()/3))))+(e->m_Rooms.GetLength()/3);
	for(i=0;i<j;i++)
	{
		x = ox+1+(rand()%((sx-1)*5));
		y = oy+1+(rand()%((sy-1)*5));
		if(e->m_Room==(CRoom *)e->m_Rooms.Get(1))
		{
			while(x<ox+1+6&&y<oy+1+6)
			{
				x = ox+1+(rand()%((sx-1)*5));
				y = oy+1+(rand()%((sy-1)*5));
			};
		};
		d1=0;
		for(k=0;k<e->m_Room->m_Objects.GetLength();k++)
			if((((CObject *)e->m_Room->m_Objects.Get(k))->m_X==x&&((CObject *)e->m_Room->m_Objects.Get(k))->m_Y==y)||e->m_Room->m_Map[x][y][1]==1)
				d1=1;
		if(d1==0)
		{
			if((rand()%30)==0)
				sprintf(b,"Enemy %d",((e->m_Rooms.GetLength()/3)-1)+1);
			else
				sprintf(b,"Enemy %d",((e->m_Rooms.GetLength()/3)-1));
			e->m_Groups.Spawn(b,x,y);//SpawnObject(rand()%(m_MasterObjects.GetLength()),x,y);
		}
		else
			i--;
	};
	j = 2+(rand()%4);
	for(i=0;i<j;i++)
	{
		x = ox+1+(rand()%((sx-1)*5));
		y = oy+1+(rand()%((sy-1)*5));
		d1=0;
		for(k=0;k<e->m_Room->m_Objects.GetLength();k++)
			if((((CObject *)e->m_Room->m_Objects.Get(k))->m_X==x&&((CObject *)e->m_Room->m_Objects.Get(k))->m_Y==y)||e->m_Room->m_Map[x][y][1]==1)
				d1=1;
		if(d1==0)
			e->m_Groups.Spawn("Food",x,y);//SpawnObject(rand()%(m_MasterObjects.GetLength()),x,y);
		else
			i--;
	};
	j = 1+(rand()%4);
	for(i=0;i<j;i++)
	{
		x = ox+1+(rand()%((sx-1)*5));
		y = oy+1+(rand()%((sy-1)*5));
		d1=0;
		for(k=0;k<e->m_Room->m_Objects.GetLength();k++)
			if((((CObject *)e->m_Room->m_Objects.Get(k))->m_X==x&&((CObject *)e->m_Room->m_Objects.Get(k))->m_Y==y)||e->m_Room->m_Map[x][y][1]==1)
				d1=1;
		if(d1==0)
			e->m_Groups.Spawn("Water",x,y);//SpawnObject(rand()%(m_MasterObjects.GetLength()),x,y);
		else
			i--;
	};
	j = 1+(rand()%10);
	for(i=0;i<j;i++)
	{
		x = ox+1+(rand()%((sx-1)*5));
		y = oy+1+(rand()%((sy-1)*5));
		d1=0;
		for(k=0;k<e->m_Room->m_Objects.GetLength();k++)
			if((((CObject *)e->m_Room->m_Objects.Get(k))->m_X==x&&((CObject *)e->m_Room->m_Objects.Get(k))->m_Y==y)||e->m_Room->m_Map[x][y][1]==1)
				d1=1;
		if(d1==0)
		{
			if((rand()%6)==0)
				sprintf(b,"Item %d",((e->m_Rooms.GetLength()/3)-1)+1);
			else
				sprintf(b,"Item %d",((e->m_Rooms.GetLength()/3)-1));
			e->m_Groups.Spawn(b,x,y);//SpawnObject(rand()%(m_MasterObjects.GetLength()),x,y);
		}
		else
			i--;
	};
};
void CGame::SpawnObject(int n,int x,int y)
{
	CEngine *e;
	e = (CEngine *)GetEngine();
	((CObject *)e->m_Game.m_MasterObjects.Get(n))->SpawnSelf(x,y);
};
CObject *CGame::GetPlayer()
{
	return GetType(1);
};
CObject *CGame::GetType(int t)
{
	CEngine *e;
	int i,j;
	e = (CEngine *)GetEngine();
	j = e->m_Room->m_Objects.GetLength();
	for(i=0;i<j;i++)
		if(((CObject *)e->m_Room->m_Objects.Get(i))->GetType()==t)
			return (CObject *)e->m_Room->m_Objects.Get(i);
};
void CGame::Load()
{
	CEngine *e;
	int i;
	e = (CEngine *)GetEngine();
	e->m_Tiles.LoadTile(".");
	e->m_Tiles.LoadTile("#");
	e->m_Tiles.LoadTile("@");
	e->m_Tiles.LoadTile("<");
	e->m_Tiles.LoadTile(">");
	e->m_Tiles.LoadTile("+");
	e->m_Tiles.LoadTile(",");
	e->m_Tiles.LoadTile("'");
	e->m_Tiles.LoadTile("*");
	e->m_Tiles.LoadTile("-");
	e->m_Tiles.LoadTile("|");
	e->m_Tiles.LoadTile("%");
	e->m_Tiles.LoadTile("T");
	e->m_Tiles.LoadTile("?");//13
	e->m_Tiles.LoadTile("$");//14
	e->m_Tiles.LoadTile("E");//15
	e->m_Tiles.LoadTile("r");//16
	e->m_Tiles.LoadTile("T");//17
	e->m_Tiles.LoadTile("C");//18
	e->m_Tiles.LoadTile("W");//19
	e->m_Tiles.LoadTile("F");//20
	e->m_Tiles.LoadTile("l");//21
	e->m_Tiles.LoadTile("p");//22
	e->m_Tiles.LoadTile("c");//23
	e->m_Tiles.LoadTile("m");//24
	e->m_Tiles.LoadTile("d");//25
	e->m_Tiles.LoadTile("b");//26
	e->m_Tiles.LoadTile("s");//27
	e->m_Tiles.LoadTile("t");//28
	e->m_Tiles.LoadTile("u");//29
	e->m_Tiles.LoadTile("a");//30
	e->m_Tiles.LoadTile("f");//31
	LoadObjects();
	e->m_Rooms.Add(new CRoom());
	e->m_Rooms.Add(new CRoom());
	e->m_Rooms.Add(new CRoom());
	e->m_Rooms.Add(new CRoom());
	e->m_Rooms.Add(new CRoom());
	e->m_Rooms.Add(new CRoom());
	e->m_Rooms.Add(new CRoom());
	e->m_Rooms.Add(new CRoom());
	e->m_Room = (CRoom *)e->m_Rooms.Get(0);
	Generate(16,5,0,0);
	e->m_Room = (CRoom *)e->m_Rooms.Get(1);
	e->m_Room->m_Objects.Add(new CPlayer());
	Generate(9,4,20,3);
	e->m_Room = (CRoom *)e->m_Rooms.Get(2);
	Generate(9,4,20,3);
	e->m_Room = (CRoom *)e->m_Rooms.Get(3);
	Generate(10,5,20,0);
	e->m_Room = (CRoom *)e->m_Rooms.Get(4);
	Generate(12,5,20,0);
	e->m_Room = (CRoom *)e->m_Rooms.Get(5);
	Generate(12,5,20,0);
	e->m_Room = (CRoom *)e->m_Rooms.Get(6);
	Generate(12,5,20,0);
	e->m_Room = (CRoom *)e->m_Rooms.Get(7);
	Generate(16,5,0,0);
	for(i=0;i<24;i++)
	{
		e->m_Rooms.Add(new CRoom());
		e->m_Room = (CRoom *)e->m_Rooms.Get(i+8);
		Generate(16,5,0,0);
	};
	e->m_Room = (CRoom *)e->m_Rooms.Get(1);
	Title();
};
void CGame::LoadObjects()
{
	CEngine *e;
	e = (CEngine *)GetEngine();//1-3 Beginning, 4-5 - 2, 6 - 3, 7-8 - 4, 9-10 - 5
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("a white rabbit","gnaws",1,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("clock","bites",2,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("ants","crawl on",3,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("coworker","hits",2,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("crawling toaster","burns",2,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("lettuce","bites",1,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("a square","bites",2,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("a circle","bites",2,100.0f,100.0f,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 1","","",new CEnemy("a triangle","bites",2,100.0f,100.0f,100,100,100,100,16)));

	m_MasterObjects.Add(AddGroup("Enemy 2","","",new CEnemy("walking table","hits",5,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 2","","",new CEnemy("walking chair","bites",5,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 2","","",new CEnemy("walking table","hits",5,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 2","","",new CEnemy("coworker","hits",5,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 2","","",new CEnemy("your friend","hurts",5,100,100,100,100,100,100,16)));
	
	m_MasterObjects.Add(AddGroup("Enemy 3","","",new CEnemy("walking couch","bites",10,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 4","","",new CEnemy("wall with hands","grabs",15,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 5","","",new CEnemy("lies","hurt",20,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 6","","",new CEnemy("programmer","programs",25,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 7","","",new CEnemy("chemist","mixes",30,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 8","","",new CEnemy("the flu","sickens",35,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 9","","",new CEnemy("prejudice","hates",40,100,100,100,100,100,100,16)));
	m_MasterObjects.Add(AddGroup("Enemy 10","","",new CEnemy("romanticism","lies to",45,100,100,100,100,100,100,16)));

	m_MasterObjects.Add(AddGroup("Item 1","Armor 1","",new CArmor("Socks",0,13,1)));
	m_MasterObjects.Add(AddGroup("Item 2","Armor 2","",new CArmor("Shoes",0,13,5)));
	m_MasterObjects.Add(AddGroup("Item 3","Armor 3","",new CArmor("Pants",0,13,10)));
	m_MasterObjects.Add(AddGroup("Item 4","Armor 4","",new CArmor("Shirt",0,13,15)));
	m_MasterObjects.Add(AddGroup("Item 5","Armor 5","",new CArmor("Jacket",0,13,20)));
	
	m_MasterObjects.Add(AddGroup("Item 6","Armor 6","",new CArmor("Large Jacket",0,13,25)));
	m_MasterObjects.Add(AddGroup("Item 7","Armor 7","",new CArmor("Raincoat",0,13,30)));
	m_MasterObjects.Add(AddGroup("Item 8","Armor 8","",new CArmor("Two Jackets",0,13,35)));
	m_MasterObjects.Add(AddGroup("Item 9","Armor 9","",new CArmor("Gloves",0,13,40)));
	m_MasterObjects.Add(AddGroup("Item 10","Armor 10","",new CArmor("Hat",0,13,45)));
	
	m_MasterObjects.Add(AddGroup("Item 1","Weapon 1","",new CWeapon("Hammer",-1,13,1,10,100)));
	m_MasterObjects.Add(AddGroup("Item 2","Weapon 2","",new CWeapon("Chainsaw",-1,13,5,10,100)));
	m_MasterObjects.Add(AddGroup("Item 3","Weapon 3","",new CWeapon("Shotgun",-1,13,10,10,100)));
	m_MasterObjects.Add(AddGroup("Item 4","Weapon 4","",new CWeapon("Algebra",-1,13,15,10,100)));
	m_MasterObjects.Add(AddGroup("Item 5","Weapon 5","",new CWeapon("Associates Degree",-1,13,20,10,100)));
	m_MasterObjects.Add(AddGroup("Item 6","Weapon 6","",new CWeapon("Bachelors Degree",-1,13,25,10,100)));
	m_MasterObjects.Add(AddGroup("Item 7","Weapon 7","",new CWeapon("Statistics",-1,13,30,10,100)));
	m_MasterObjects.Add(AddGroup("Item 8","Weapon 8","",new CWeapon("Calculus",-1,13,35,10,100)));
	m_MasterObjects.Add(AddGroup("Item 9","Weapon 9","",new CWeapon("AES Encryption",-1,13,40,10,100)));
	m_MasterObjects.Add(AddGroup("Item 10","Weapon 10","",new CWeapon("The Truth",-1,13,45,10,100)));
	
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Food 1",true,false,false,13,true,100)));
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Water 1",true,false,false,13,false,100)));
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Food 2",true,false,false,13,true,200)));
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Water 2",true,false,false,13,false,200)));
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Food 3",true,false,false,13,true,400)));
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Water 3",true,false,false,13,false,400)));
	/*
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("a white rabbit","hits",0,8,0,0,8,8,50,16)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("Romanticism","lies to",0,8,0,0,8,8,50,16)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("walking table","bites",0,8,0,0,8,8,50,17)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("walking couch","eats",0,8,0,0,8,8,50,18)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("clock","bites",0,8,0,0,8,8,50,18)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("fridge with teeth","bites",0,8,0,0,8,8,50,20)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("washing machine with teeth","bites",0,8,0,0,8,8,50,19)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("wall with hands","hits",0,8,0,0,8,8,50,19)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("flying table","bites",0,8,0,0,8,8,50,17)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("lies","hits",0,8,0,0,8,8,50,21)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("lawyer","sues",0,8,0,0,8,8,50,21)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("programmer","programs",0,8,0,0,8,8,50,22)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("chemist","hits",0,8,0,0,8,8,50,23)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("flying clock","hits",0,8,0,0,8,8,50,23)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("police officer","shoots",0,8,0,0,8,8,50,22)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("fire fighter","hits",0,8,0,0,8,8,50,31)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("your mother","hurts",0,8,0,0,8,8,50,24)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("your dad","hurts",0,8,0,0,8,8,50,25)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("your brother","hurts",0,8,0,0,8,8,50,26)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("falling bricks","hits",0,8,0,0,8,8,50,26)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("your sister","hurts",0,8,0,0,8,8,50,27)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("flying toaster","burns",0,8,0,0,8,8,50,28)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("crawling telephone","strangles",0,8,0,0,8,8,50,28)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("black dog","bites",0,8,0,0,8,8,50,25)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("flying books","bites",0,8,0,0,8,8,50,26)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("your uncle","hurts",0,8,0,0,8,8,50,29)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("your aunt","hurts",0,8,0,0,8,8,50,30)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("ants","hits",0,8,0,0,8,8,50,30)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("your friend","hits",0,8,0,0,8,8,50,31)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("a square","hits",0,8,0,0,8,8,50,27)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("a circle","hits",0,8,0,0,8,8,50,23)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("a triangle","hits",0,8,0,0,8,8,50,28)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("a snake","bites",0,8,0,0,8,8,50,27)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("television show","hurts",0,8,0,0,8,8,50,17)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("lettuce","bites",0,8,0,0,8,8,50,21)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("car","runs over",0,8,0,0,8,8,50,18)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("bus","runs over",0,8,0,0,8,8,50,26)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("angry boss","yells at",0,8,0,0,8,8,50,26)));
	m_MasterObjects.Add(AddGroup("Enemy","","",new CEnemy("coworker","hits",0,8,0,0,8,8,50,23)));
	//Rug
	//Living Vaccum.
	
	
	m_MasterObjects.Add(AddGroup("Item","Armor","",new CArmor("Shoes",0,13,2)));
	m_MasterObjects.Add(AddGroup("Item","Armor","",new CArmor("Sneakers",0,13,3)));
	m_MasterObjects.Add(AddGroup("Item","Armor","",new CArmor("Socks",0,13,1)));
	m_MasterObjects.Add(AddGroup("Item","Armor","",new CArmor("Shirt",1,13,3)));
	m_MasterObjects.Add(AddGroup("Item","Armor","",new CArmor("Coat",2,13,4)));
	m_MasterObjects.Add(AddGroup("Item","Armor","",new CArmor("Raincoat",2,13,5)));
	m_MasterObjects.Add(AddGroup("Item","Armor","",new CArmor("Jacket",2,13,5)));

	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Algebra",-1,13,0,7)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Statistics",-1,13,0,8)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Trigonometry",-1,13,0,10)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Associates degree",-1,13,0,5)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Hand gun",-1,13,0,5)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Sword",-1,13,1,3)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Pen",-1,13,1,3)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Shotgun",-1,13,0,20)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Bachelors degree",-1,13,0,7)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Masters degree",-1,13,0,10)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("AES Encryption",-1,13,0,3)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("DES Encryptioon",-1,13,0,10)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Piggy Bank",-1,13,1,10)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Chainsaw",-1,13,1,18)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Ax",-1,13,1,8)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Drill",-1,13,1,8)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Electric Saw",-1,13,1,10)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Hammer",-1,13,1,5)));
	m_MasterObjects.Add(AddGroup("Item","Weapon","",new CWeapon("Butcher Knife",-1,13,1,12)));
	
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Birthday Cake",true,false,false,13,true,200)));
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Cake",true,false,false,13,true,200)));
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Pie",true,false,false,13,true,200)));
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Ice Cream",true,false,false,13,true,200)));
	m_MasterObjects.Add(AddGroup("Item","Food","",new CItem("Cheese burger",true,false,false,13,true,200)));
	
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Soda",true,false,false,13,false,200)));
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Milk",true,false,false,13,false,200)));
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Water",true,false,false,13,false,200)));
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Flavored sugar water",true,false,false,13,false,200)));
	m_MasterObjects.Add(AddGroup("Item","Water","",new CItem("Chocolate milk",true,false,false,13,false,200)));
/*
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Algebra",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Statistics",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Trigonometry",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Associates degree",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Bachelors degree",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Masters degree",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("DES Encryption",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("AES Encryption",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Elliptic curve encryption",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Hand gun",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Shot gun",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Kitchen knife",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Pen",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Sword",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Piggy bank",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Pan",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Chainsaw",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Drill",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Ax",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Watch",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Saw",false,false,false,13)));
	m_MasterObjects.Add(AddGroup("test","","",new CItem("Hammer",false,false,false,13)));*/
};
CObject *CGame::AddGroup(char *g,char *g2,char *g3,CObject *o)
{
	CEngine *e;
	e = (CEngine *)GetEngine();
	e->m_Groups.Add(g,o);
	if(strlen(g2)>1)
		e->m_Groups.Add(g2,o);
	if(strlen(g3)>1)
		e->m_Groups.Add(g3,o);
	return o;
};
void CGame::Run()
{
	
};
void CGame::Title()
{
	char b[255];
	clear();
	echo();
	mvprintw(0, 0, "DreamHack\nCreated by Bryan Strait.\nInspired by Nethack, based on Hack.\n\n\n\nWhat is your name? ");
	getnstr(b,255);
	curs_set(0);
	mvprintw(0, 0, "You have fallen asleep. You dream that your house is very different. [more]\n\n\n\n\n\n\n\n\n\n\n\n");
	getch();
	getch();
	noecho();
};


CConfidences::CConfidences()
{
	Clear();
};
CConfidences::~CConfidences()
{
	Clear();
};

void CConfidences::AddConfidence(char *c)
{
	CConfidence *n;
	n = new CConfidence();
	strncpy(n->m_Name,c,255);
	m_Confidences.Add(n);
};
void CConfidences::IncreaseConfidence(char *c,int n)
{
	int i;
	for(i=0;i<m_Confidences.GetLength();i++)
		if(strncmp(((CConfidence *)m_Confidences.Get(i))->m_Name,c,255)==0)
	{
		((CConfidence *)m_Confidences.Get(i))->m_Amount+=n;
		return;
	};
};
int CConfidences::GetConfidence(char *c)
{
	int i;
	for(i=0;i<m_Confidences.GetLength();i++)
		if(strncmp(((CConfidence *)m_Confidences.Get(i))->m_Name,c,255)==0)
			return ((CConfidence *)m_Confidences.Get(i))->m_Amount;
	return 0;
};

void CConfidences::Clear()
{
	CConfidence *c;
	while(m_Confidences.GetLength()>0)
	{
		c = (CConfidence *)m_Confidences.Get(0);
		if(c!=NULL)
			delete(c);
		m_Confidences.Delete(0);
	};
};

CPlayer::CPlayer()
{
	m_Up = m_Down = m_Left = m_Right = m_Wall = false;
	m_X = 23;
	m_Y = 5;
	m_Type = 1;
	m_Health = 8;
	m_Tile = 2;
	m_Collide = true;
	m_Damage = m_Armor = m_Attack = 0;
	m_MaxDamage = 1;
	m_Health = m_MaxHealth = 100;
	strncpy(m_Name,"Player",255);
	strncpy(m_Verb,"hit",255);
	m_DrawPass = 3;
	m_HealthRate = 2;
	m_HealthProgress=0;
	m_Hunger = m_Thirst = 400;
	m_Experience = 0;
	m_Level = 1;
	m_NextLevel = 20;
	m_Confidences.AddConfidence("Attack");
	m_Confidences.AddConfidence("Defense");
	m_Confidences.AddConfidence("Health");
};
CPlayer::~CPlayer()
{
	DeleteInventory();
};
void CPlayer::DeleteInventory()
{
	CItem *i;
	while(m_Inventory.GetLength()>0)
	{
		i = (CItem *)m_Inventory.Get(0);
		if(i!=NULL)
			delete(i);
		m_Inventory.Delete(0);
	};
};
bool CPlayer::AddInvetory(CItem *i)
{
	int j;
	CEngine *e;
	CItem *i2;
	e = (CEngine *)GetEngine();
	if(i->m_MasterNum!=-1)
		for(j=0;j<m_Inventory.GetLength();j++)
			if(((CItem *)m_Inventory.Get(j))->m_MasterNum==i->m_MasterNum)
			{
				((CItem *)m_Inventory.Get(j))->m_Amount++;
				delete(i);
				return true;
			};
	if(m_Inventory.GetLength()<24)
	{
		m_Inventory.Add(i);
		return true;
	};
	return false;
};
void CPlayer::DropInventory(int n)
{
	CItem *i;
	CEngine *e;
	CPlayer *p;
	e = (CEngine *)GetEngine();
	i = (CItem *)m_Inventory.Get(n);
	p = (CPlayer *)e->m_Game.GetPlayer();
	if(i==NULL)
		return;
	i->m_X = p->m_X;
	i->m_Y = p->m_Y;
	e->m_Room->m_Objects.Add(i);
	m_Inventory.Delete(n);
};

void CPlayer::Wear(int n)
{
	CItem *i,*i2;
	int j,k;
	i = (CItem *)m_Inventory.Get(n);
	if(i==NULL)
		return;
	for(j=0;j<m_Wear.GetLength();j++)
	{
		i2 = (CItem *)m_Wear.Get(j);
		if(i2->m_WearType==i->m_WearType)
			TakeOff(j);
	};
	m_Wear.Add(i);
	m_Inventory.Delete(n);
	i->Wear();
};
void CPlayer::TakeOff(int n)
{
	CItem *i;
	i = (CItem *)m_Wear.Get(n);
	if(i==NULL)
		return;
	m_Inventory.Add(i);
	m_Wear.Delete(n);
	i->TakeOff();
};
void CPlayer::Use(int n)
{
	CItem *i;
	i = (CItem *)m_Inventory.Get(n);
	if(i==NULL)
		return;
	i->Use();
};
void CPlayer::Eat(int n)
{
	CItem *i;
	i = (CItem *)m_Inventory.Get(n);
	if(i==NULL||!i->m_Eat)
		return;
	i->Eat();
	if(i->m_Amount>1)
		i->m_Amount--;
	else
	{
		m_Inventory.Delete(n);
		delete(i);
	};
	
};

void CPlayer::ShowConfidences()
{
	int i;
	clear();
	mvprintw(0,0,"Confidences:");
	for(i=0;i<m_Confidences.m_Confidences.GetLength();i++)
		mvprintw(1+i,1,"%d - %s\n",((CConfidence *)m_Confidences.m_Confidences.Get(i))->m_Amount,((CConfidence *)m_Confidences.m_Confidences.Get(i))->m_Name);
};

void CPlayer::Run()
{
	CEngine *e;
	CObject *o;
	char msg[255];
	int i;
	e = (CEngine *)GetEngine();

	if(m_Up&&(!CollideMap(m_X,m_Y-1)||m_Wall))
		m_Y--;
	if(m_Down&&(!CollideMap(m_X,m_Y+1)||m_Wall))
		m_Y++;
	if(m_Left&&(!CollideMap(m_X-1,m_Y)||m_Wall))
		m_X--;
	if(m_Right&&(!CollideMap(m_X+1,m_Y)||m_Wall))
		m_X++;
	i=0;
	while((o=CollideObject(i))!=NULL)
	{
		if(o->m_Collide)
		{
			if(m_Up)
				m_Y++;
			if(m_Down)
				m_Y--;
			if(m_Left)
				m_X++;
			if(m_Right)
				m_X--;
			o->Message(10);
			break;
		};
		i++;
	};
	m_Up = m_Down = m_Left = m_Right = false;
	if(m_HealthProgress>m_HealthRate)
	{
		if(m_Hunger>29&&m_Thirst>29)
			m_Health++;
		else
			m_Health--;
		m_Hunger-=2;
		m_Thirst-=1;
		m_HealthProgress=0;
	}
	else
		m_HealthProgress++;
	if(m_Health>m_MaxHealth)
		m_Health=m_MaxHealth;
	sprintf(msg,"HP: %d/%d XP: %d/%d ",m_Health,m_MaxHealth,m_Experience,m_NextLevel);
	e->m_GUI.AddBottom(msg);
	if(m_Hunger>30&&m_Hunger<100)
	{
		sprintf(msg,"Hungry ");
		e->m_GUI.AddBottom(msg);
	};
	if(m_Hunger<30)
	{
		sprintf(msg,"Starving ");
		e->m_GUI.AddBottom(msg);
	};
	if(m_Hunger>500)
	{
		sprintf(msg,"Stuffed ");
		e->m_GUI.AddBottom(msg);
	};
	if(m_Thirst<100)
	{
		sprintf(msg,"Thirsty ");
		e->m_GUI.AddBottom(msg);
	};
	if(m_Thirst>600)
		m_Thirst=600;
	if(m_Hunger>600)
		m_Hunger=600;
	if(m_Experience>m_NextLevel-1)
	{
		GainLevel();
		m_Level++;
		m_Experience = 0;
		m_NextLevel=(int)((float)m_NextLevel*1.5f);
		m_MaxHealth+=2+(rand()%(2+(m_Confidences.GetConfidence("Health")/4)));
	};
	if(m_Health<0&&!m_Wall)
	{
		e->m_GUI.AddTop("You die... [press any key to continue]\n",true);
		EndGame();
	};
};

void CPlayer::Draw()
{
	CEngine *e;
	int i;
	e = (CEngine *)GetEngine();
	
	e->m_Tiles.DrawTile(m_Tile,(m_X-e->m_Room->m_CameraX),(m_Y-e->m_Room->m_CameraY));
};
void CPlayer::EndGame()
{
	CEngine *e;
	e = (CEngine *)GetEngine();
	e->m_On = false;
};

void CPlayer::Input(int e)
{
	CEngine *en;
	CObject *o,*o2;
	int i;
	en = (CEngine *)GetEngine();
	switch(e)
	{
		case KEY_UP:
			m_Up = true;
			break;
		case KEY_DOWN:
			m_Down = true;
			break;
		case KEY_LEFT:
			m_Left = true;
			break;
		case KEY_RIGHT:
			m_Right = true;
			break;
		case '>':
		case '<':
			o = CollideObject(0);
			if(o!=NULL)
				o->Message(0);
			else if(m_Wall)
			{
				if(e=='>')
					o = new CStairs(false);
				else
					o = new CStairs(true);
				o->Message(0);
				delete(o);
			};
			break;
		case 'g':
			o = CollideObject(0);
			if(o!=NULL&&o->m_Type==6)
			{
				if(AddInvetory((CItem *)o))
					en->m_Room->m_Objects.Delete(en->m_Room->m_Objects.Find(o));
				else
				{
					mvprintw(0,0,"Your inventory is full. You have to drop something before picking anything up.");
					getch();
				};
			};
			break;
		case 'i':
			ShowInventory();
			refresh();
			getch();
			break;
		case 'E':
			ShowWearing();
			refresh();
			getch();
			break;
		case 'W':
			m_Wall = !m_Wall;
			break;
		case 'u':
			mvprintw(0,0,"Use what? (? for inventory)\n");
			i = getch();
			while(i=='?')
			{
				ShowInventory();
				mvprintw(0,0,"Use what?\n");
				i = getch();
			};
			i-='a';
			Use(i);
			break;
		case 'w':
			mvprintw(0,0,"Wear or hold what? (? for inventory)\n");
			i = getch();
			while(i=='?')
			{
				ShowInventory();
				mvprintw(0,0,"Wear or hold what?\n");
				i = getch();
			};
			i-='a';
			Wear(i);
			break;
		case 'r':
			o = en->m_Game.GetPlayer();
			if(((CPlayer *)o)->m_Hunger<29)
			{
				mvprintw(0,0,"You are too hungry to rest.\n");
				getch();
				return;
			};
			
			if(en->m_Game.m_SeenEnemies>0)
			{
				mvprintw(0,0,"You can't rest with enemies nearby.\n");
				getch();
				return;
			};
			
			mvprintw(0,0,"Rest for how many turns? (+1 health each turn) ");
			echo();
			curs_set(1);
			scanw("%d\n",&i);
			curs_set(0);
			noecho();
			((CPlayer *)o)->m_Health+=i;
			((CPlayer *)o)->m_Hunger-=i;
			((CPlayer *)o)->m_Thirst-=(i/4);
			break;
		case 'e':
			mvprintw(0,0,"Eat or drink what? (? for inventory)\n");
			i = getch();
			while(i=='?')
			{
				ShowInventory();
				mvprintw(0,0,"Eat or drink what?\n");
				i = getch();
			};
			i-='a';
			Eat(i);
			break;
		case 'c':
			ShowConfidences();
			refresh();
			getch();
			break;
		case 't':
			mvprintw(0,0,"Take off what? (? for inventory)\n");
			i = getch();
			while(i=='?')
			{
				ShowWearing();
				mvprintw(0,0,"Take off what?\n");
				i = getch();
			};
			i-='a';
			TakeOff(i);
			break;
		case 'd':
			mvprintw(0,0,"Drop what? (? for inventory)\n");
			i = getch();
			while(i=='?')
			{
				ShowInventory();
				mvprintw(0,0,"Drop what?\n");
				i = getch();
			};
			i-='a';
			DropInventory(i);
			break;
		case '?':
			mvprintw(0,0,"Keys:\n");
			printw(" w - Wear/Hold\n");
			printw(" e - Eat/Drink\n");
			printw(" u - Use\n");
			printw(" g - Get\n");
			printw(" i - Inventory\n");
			printw(" E - View worn/held items\n");
			printw(" W - \"Wizard\" mode\n");
			printw(" q - Quit\n");
			printw(" o - Open/Close\n");
			printw(" d - Drop\n");
			printw(" t - Take off\n");
			printw(" r - Rest\n");
			printw(" c - View confidences\n");
			getch();
			break;
		case 'o':
			mvprintw(0,0,"Open or close what? (direction)\n");
			switch(getch())
			{
				case KEY_UP:
					m_Y--;
					o = CollideObject(0);
					if(o!=NULL)
						o->Message(1);
					m_Y++;
					break;
				case KEY_DOWN:
					m_Y++;
					o = CollideObject(0);
					if(o!=NULL)
						o->Message(1);
					m_Y--;
					break;
				case KEY_LEFT:
					m_X--;
					o = CollideObject(0);
					if(o!=NULL)
						o->Message(1);
					m_X++;
					break;
				case KEY_RIGHT:
					m_X++;
					o = CollideObject(0);
					if(o!=NULL)
						o->Message(1);
					m_X--;
					break;
			};
			break;
	};
};
void CPlayer::GainLevel()
{
	int i,n,s;
	if(m_Level!=1)
		n = 2+(rand()%3);
	else
		n = 6;
	s = 0;
	clear();
	mvprintw(0,0,"You gained a level! Press space to continue.");
	while(getch()!=' ');
	while(1==1)
	{
		ShowConfidences();
		mvprintw(0,0,"Distribute points to your confidences: (%d points left) (q to exit)\n",n);
		mvprintw(1+s,0,">");
		i = getch();
		
		switch(i)
		{
			case KEY_UP:
				s--;
				break;
			case KEY_DOWN:
				s++;
				break;
			case KEY_LEFT:
				break;
			case KEY_RIGHT:
				if(n<1)
					break;
				((CConfidence *)m_Confidences.m_Confidences.Get(s))->m_Amount++;
				n--;
				break;
			case 'q':
				if(n<1)
					return;
				else
				{
					mvprintw(0,0,"You still have points left to distribute!\n");
					getch();
				};
				break;
		};
		if(s<0)
			s=0;
		if(s>m_Confidences.m_Confidences.GetLength())
			s = m_Confidences.m_Confidences.GetLength()-1;
	};
};
void CPlayer::ShowInventory()
{
	int i;
	mvprintw(0,40,"Inventory");
	for(i=0;i<m_Inventory.GetLength();i++)
		if(((CItem *)m_Inventory.Get(i))->m_Amount>1)
			mvprintw(i+1,40,"%c - %d %s",i+'a',((CItem *)m_Inventory.Get(i))->m_Amount,((CItem *)m_Inventory.Get(i))->m_Name);
		else
			mvprintw(i+1,40,"%c - %s",i+'a',((CItem *)m_Inventory.Get(i))->m_Name);
};
void CPlayer::ShowWearing()
{
	int i;
	mvprintw(0,40,"Wearing");
	for(i=0;i<m_Wear.GetLength();i++)
		mvprintw(i+1,40,"%c - %s",i+'a',((CItem *)m_Wear.Get(i))->m_Name);
};
void CPlayer::Message(int m)
{
};
CDoor::CDoor(int x,int y)
{
	m_Open = false;
	m_X = x;
	m_Y = y;
	m_Tile = 5;
	m_Type = 2;
	m_Clear = false;
	m_Collide = true;
	m_DrawPass = 0;
};

void CDoor::Message(int m)
{
	if(m==1||m==10)
		m_Open = !m_Open;
	if(m_Open)
		m_Tile = 6;
	else
		m_Tile = 5;
	if(m_Open)
		m_Clear=true;
	else
		m_Clear=false;
	if(m_Open)
		m_Collide = false;
	else
		m_Collide = true;
};
CStairs::CStairs(bool d)
{
	m_Up = d;
	if(d)
		m_Tile=m_Type=3;
	else
		m_Tile=m_Type=4;
	m_DrawPass = 0;
};
CStairs::~CStairs()
{
};
void CStairs::Message(int m)
{
	CEngine *e;
	CPlayer *p;
	CObject *o;
	int r;
	e = (CEngine *)GetEngine();
	if(m==0)
		if(m_Up)
		{	
			if(e->m_Rooms.Find(e->m_Room)<e->m_Rooms.GetLength())
			{
				r = e->m_Rooms.Find(e->m_Room)+1;
				if(r>0&&r<e->m_Rooms.GetLength())
				{
					mvprintw(0,0,"You go up.\n");
					getch();
					p = (CPlayer *)e->m_Game.GetPlayer();
					e->m_Room->m_Objects.Delete(e->m_Room->m_Objects.Find(p));
					e->m_Room = (CRoom *)e->m_Rooms.Get(r);
					e->m_Room->m_Objects.Add(p);
					o=e->m_Game.GetType(4);
					p->m_X = o->m_X;
					p->m_Y = o->m_Y;
				};
			};
			
		}
		else
		{
			if(e->m_Rooms.Find(e->m_Room)<e->m_Rooms.GetLength())
			{
				r = e->m_Rooms.Find(e->m_Room)-1;
				if(r>-1&&r<e->m_Rooms.GetLength())
				{
					mvprintw(0,0,"You go down.\n");
					getch();
					p = (CPlayer *)e->m_Game.GetPlayer();
					e->m_Room->m_Objects.Delete(e->m_Room->m_Objects.Find(p));
					e->m_Room = (CRoom *)e->m_Rooms.Get(r);
					e->m_Room->m_Objects.Add(p);
					o=e->m_Game.GetType(3);
					p->m_X = o->m_X;
					p->m_Y = o->m_Y;
				};
			};
		};
};


CEnemy::CEnemy()
{
	m_Damage = m_Armor = m_Attack = m_HealthProgress = 0;
	m_MaxDamage = m_Health = m_MaxHealth = 8;
	m_HealthRate = 50;
	strncpy(m_Name,"Enemy",255);
	strncpy(m_Verb,"hits",255);
	m_Tile = 15;
	m_Type = 5;
	m_Collide = true;
	m_DrawPass = 2;
	m_Experience = 1+(rand()%4);
};
	//Enemy Hp: hp = (level*10)+(0 to level). Each level enemies can increase a skill by 2.
	//Groups of enemies every 5 floors, in 5 floors the player can increase 5 levels
	//Therefore each group of enemies should be 5 levels higher than the last.
	//Experience should match up, such that the player can only get 5 levels in 5 floors.
	//XP from enemies for 5 levels needs to = what the player needs to gain 5 levels.
	//1.332 to the 5th, times starting next level XP to be exact. Each floor must have
	//an exact experience value of enemies. Each floor should spawn ((RequiredXPForPlayerLevel*0.9)/EnemyLevelAsXP) enemies
	//EnemyXP is determined by XPRequiredToGainLevelAtLevelOfEnemy/DefaultEnemyNumber
	//Damage increase per level is worth 2 points of total enemy pool. Enemy pool
	//should be (level*2) (Each level enemy can gain 2 points) (Player gets 3)
	//Each group could have enemies of levels up to 4 over the group's base level.
CEnemy::CEnemy(char *n,char *v,int l,float d,float md,float ar,float a,float mh,float hr,int t)
{
	float points;
	float total;
	strncpy(m_Name,"Enemy",255);
	strncpy(m_Verb,"hits",255);
	strncpy(m_Name,n,255);
	strncpy(m_Verb,v,255);
	points = l*2;
	total = d+md+ar+a+mh+hr;
	if(total!=1.0f)
	{
		d/=total;
		md/=total;
		ar/=total;
		a/=total;
		mh/=total;
		hr/=total;
	};
	m_Damage = 1+((float)d*(float)points);
	m_MaxDamage = 3+((float)md*(float)points);
	m_Armor = (ar*points);
	m_Attack = (a*points);
	m_Health = m_MaxHealth = 20+((mh*points)+(l*5));
	m_HealthRate = 70-(hr*points);
	m_Tile = t;
	m_Type = 5;
	m_Collide = true;
	m_DrawPass = 2;
};
CEnemy::~CEnemy()
{
};

CEnemy *CEnemy::SpawnSelf(int x,int y)
{
	CEnemy *o;
	CEngine *e;
	e = (CEngine *)GetEngine();
	o = new CEnemy();
	o->m_X = x;
	o->m_Y = y;
	o->m_Collide = m_Collide;
	o->m_Shown = m_Shown;
	o->m_Clear = m_Clear;
	o->m_Type = m_Type;
	o->m_Tile = m_Tile;
	o->m_Damage = m_Damage;
	o->m_Armor = m_Armor;
	o->m_Attack = m_Attack;
	o->m_HealthProgress = m_HealthProgress;
	o->m_MaxDamage = m_MaxDamage;
	o->m_Health = m_Health;
	o->m_MaxHealth = m_MaxHealth;
	o->m_HealthRate = m_HealthRate;
	strncpy(o->m_Name,m_Name,255);
	strncpy(o->m_Verb,m_Verb,255);
	e->m_Room->m_Objects.Add(o);
	return o;
};

void CEnemy::Run()
{
	if(m_Health>-1)
		AI();
	else
		Die();
};
void CEnemy::Message(int m)
{
	if(m==10)
		Defend();
};

void CEnemy::AI()
{
	CEngine *e;
	CPlayer *p;
	int i;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	m_HealthProgress++;
	if(m_Health<m_MaxHealth&&m_HealthProgress>m_HealthRate)
	{
		m_Health++;
		m_HealthProgress=0;
	};
	if(abs(m_X-p->m_X)>4||abs(m_Y-p->m_Y)>4)
	{
		i = rand()%4;
		if(i==0)
			Move(m_X,m_Y-1,false);
		if(i==1)
			Move(m_X,m_Y+1,false);
		if(i==2)
			Move(m_X-1,m_Y,false);
		if(i==3)
			Move(m_X+1,m_Y,false);
	}
	else
	{
		i = 0;
		if(p->m_X<m_X&&rand()%5==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X-1,m_Y,false);
			else
				Move(m_X+1,m_Y,false);
			i = 1;
		};
		if(p->m_Y<m_Y&&i==0&&rand()%2==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X,m_Y-1,false);
			else
				Move(m_X,m_Y+1,false);
			i = 1;
		};
		if(p->m_X>m_X&&i==0&&rand()%5==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X+1,m_Y,false);
			else
				Move(m_X-1,m_Y,false);
			i = 1;
		};
		if(p->m_Y>m_Y&&i==0&&rand()%2==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X,m_Y+1,false);
			else
				Move(m_X,m_Y-1,false);
			i=1;
		};
		
		
		if(p->m_X<m_X&&i==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X-1,m_Y,false);
			else
				Move(m_X+1,m_Y,false);
			i = 1;
		};
		if(p->m_Y<m_Y&&i==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X,m_Y-1,false);
			else
				Move(m_X,m_Y+1,false);
			i = 1;
		};
		if(p->m_X>m_X&&i==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X+1,m_Y,false);
			else
				Move(m_X-1,m_Y,false);
			i = 1;
		};
		if(p->m_Y>m_Y&&i==0)
		{
			if(m_Health>m_MaxHealth/3)
				Move(m_X,m_Y+1,false);
			else
				Move(m_X,m_Y-1,false);
			i=1;
		};
		if(i==0)
		{
			mvprintw(0,0,"ERROR.");
			getch();
		};
		Attack(false);
	};
};

//Damage reduction is worth twice damage resistance. Could either multiply i by attack or 15 by attack. 15 could be
//multiplied by player defence, i could be multiplied by attack. Maybe. i could be first multiplied by %attack+1.0f,
//then multiplied by ... maybe 15 is then multiplied by 1.0f+%playerdefense.  Attack is then worth 4x defense, roughly.
//Maybe attack is multiplied by defense. Have to make sure that defense doesn't grow
//toward infinity while attack only grows toward doubling. i*=(1.0f+(%attack*(1.0f-%defense)))
//This still makes defense more worthwhile than attack because 100 defense = 0 attack, versus 100 attack
//has no such correlation to defense. 0.05% attack * 0.95 = something like 0.48, so 5% defense isn't worth
// 5% attack. 0.5 * 0.5 = 0.25.  Maybe we should instead multiply 15, as it is constant instead of random.
// requiredtohit=15*(1.0f-(%attack-%defense)); if attack is 0 and defense is 100, 1.0 drops to 0.0, which
//might be unbalanced. If attack = 100 and d = 0 we increase to 30, which is infinity as far as we're concerned.
// so 100 v 0 always wins, no matter if it's attack or defense. if 50 v 50, 1.0+0, so 15, balanced.
void CEnemy::Attack(bool f)
{
	CEngine *e;
	CPlayer *p;
	char msg[255];
	int i;
	float j;
	bool d;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	i = abs(m_X-p->m_X);
	j = abs(m_Y-p->m_Y);
	if(i>1||j>1)
		return;
	i = (rand()%30);
	if(i==29)
		d=true;
	else
		d=false;
	//i+=m_Attack;
	//i-=p->m_Armor+(p->m_Confidences.GetConfidence("Defense")/3);
	if(i<16)
		i=0;
	j = 15.0f*(1.0f-(((float)m_Attack/100.0f)-((float)p->m_Confidences.GetConfidence("Defense")/100.0f)));
	if(i>j||d)
	{
		i = m_Damage+(rand()%(int)(m_MaxDamage-m_Damage));
		if(d)
			i*=3;
		i-=p->m_Armor;
		if(i<0)
			i=0;
		if(i==0&&d)
			i = 1;
		p->m_Health-=i;
		p->Message(30);
	};
	if(i!=0)
	{
		if(!d)
			sprintf(msg,"%s %s you for %d. ",m_Name,m_Verb,i);
		else
			sprintf(msg,"%s %s you for %d! ",m_Name,m_Verb,i);
	}
	else
		sprintf(msg,"%s misses. ",m_Name);
	e->m_GUI.AddTop(msg,true);
};
void CEnemy::Defend()
{
	CEngine *e;
	CPlayer *p;
	char msg[255];
	int i;
	float j;
	bool d;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	i = (rand()%30);
	if(i==29)
		d=true;
	else
		d=false;
	//i+=p->m_Attack+(p->m_Confidences.GetConfidence("Attack")/3);
	//i-=m_Armor;
	if(i<16)
		i=0;
	j = 15.0f*(1.0f-(((float)p->m_Attack/100.0f)-((float)m_Armor/100.0f)));
	if(i>j||d)
	{
		i = p->m_Damage+(rand()%(int)(p->m_MaxDamage-p->m_Damage));
		if(d)
			i*=3;
		i-=m_Armor;
		if(i<0)
			i=0;
		if(i==0&&d)
			i = 1;
		m_Health-=i;
	};
	if(i!=0)
	{
		if(!d)
			sprintf(msg,"You %s %s for %d. ",p->m_Verb,m_Name,i);
		else
			sprintf(msg,"You %s %s for %d! ",p->m_Verb,m_Name,i);
	}
	else
		sprintf(msg,"You missed %s. ",m_Name);
	if(m_Health<0)
	{
		sprintf(msg,"You killed %s! (%d) ",m_Name,i);
		p->m_Experience+=m_Experience;
	};
	e->m_GUI.AddTop(msg,true);
};
void CEnemy::Move(int x,int y,bool f)
{
	CObject *o;
	int i;
	int x2,y2;
	if(CollideMap(x,y)&&!f)
		return;
	i=0;
	x2 = m_X;
	y2 = m_Y;
	m_X = x;
	m_Y = y;
	o=CollideObject(i);
	while(o!=NULL)
	{
		if(o->m_Collide)
		{
			o->Message(30);
			if(!f)
			{
				m_X = x2;
				m_Y = y2;
				return;
			};
		};
		i++;
		o=CollideObject(i);
	};
};

CGroups::CGroups()
{
	Clear();
};
CGroups::~CGroups()
{
	Clear();
};

CObject *CGroups::Add(char *n,CObject *o)
{
	int i;
	bool f;
	f=false;
	for(i=0;i<m_Groups.GetLength();i++)
		if(strncmp(((CGroup *)m_Groups.Get(i))->m_Name,n,255)==0)
		{
			((CGroup *)m_Groups.Get(i))->m_Objects.Add(o);
			f = true;
		};
	if(!f)
	{
		m_Groups.Add(new CGroup(n));
		((CGroup *)m_Groups.Get(m_Groups.GetLength()-1))->m_Objects.Add(o);
	};
	return o;
};
CObject *CGroups::Spawn(char *n,int x,int y)
{
	int i;
	CObject *o;
	for(i=0;i<m_Groups.GetLength();i++)
		if(strncmp(((CGroup *)m_Groups.Get(i))->m_Name,n,255)==0)
		{
			o = (CObject *)((CGroup *)m_Groups.Get(i))->m_Objects.Get(rand()%(((CGroup *)m_Groups.Get(i))->m_Objects.GetLength()));
			return o->SpawnSelf(x,y);
		};
	return NULL;
};
void CGroups::Clear()
{
	CGroup *g;
	int i;
	while(m_Groups.GetLength()>0)
	{
		if(m_Groups.Get(0)!=NULL)
		{
			g = (CGroup *)m_Groups.Get(0);
			while(g->m_Objects.GetLength()>0)
				g->m_Objects.Delete(0);
			delete(g);
		};
		m_Groups.Delete(0);
	};
};

CItem::CItem()
{
};
CItem::CItem(char *n,bool e,bool w,bool u,int t,bool f,int fa)
{
	strncpy(m_Name,n,254);
	m_Eat = e;
	m_Wear = w;
	m_Use = u;
	m_Tile = t;
	m_Type = 6;
	m_Collide = false;
	m_DrawPass = 1;
	m_WearType = 0;
	m_FoodAmount = fa;
	m_FoodType = f;
	m_MasterNum = -1;
	m_Amount = 1;
};
CItem::~CItem()
{
};

CItem *CItem::SpawnSelf(int x,int y)
{
	CItem *o;
	CEngine *e;
	int i;
	e = (CEngine *)GetEngine();
	o = new CItem(m_Name,m_Eat,m_Wear,m_Use,m_Tile,m_FoodType,m_FoodAmount);
	o->m_X = x;
	o->m_Y = y;
	o->m_Collide = m_Collide;
	o->m_Shown = m_Shown;
	o->m_Clear = m_Clear;
	o->m_Type = m_Type;
	o->m_WearType = m_WearType;
	o->m_Tile = m_Tile;
	o->m_FoodType = m_FoodType;
	o->m_FoodAmount = m_FoodAmount;
	o->m_MasterNum = -1;
	o->m_Amount = m_Amount;
	for(i=0;i<e->m_Game.m_MasterObjects.GetLength();i++)
		if(((CItem *)e->m_Game.m_MasterObjects.Get(i))==this)
			o->m_MasterNum = i;
	strncpy(o->m_Name,m_Name,255);
	e->m_Room->m_Objects.Add(o);
	return o;
};

void CItem::Run()
{
};
void CItem::Message(int m)
{
	switch(m)
	{
		case 21:
			Eat();
			break;
		case 22:
			Wear();
			break;
		case 23:
			Use();
			break;
	};
};

void CItem::Eat()
{
	CEngine *e;
	CPlayer *p;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	if(!m_Eat)
		return;
	if(m_FoodType)
		p->m_Hunger+=m_FoodAmount;
	else
		p->m_Thirst+=m_FoodAmount;
};
void CItem::Wear()
{
};
void CItem::TakeOff()
{
};
void CItem::Use()
{
};

void CItem::AI()
{
};

CArmor::CArmor(char *n,int w,int t,int a)
{
	strncpy(m_Name,n,255);
	m_Eat = false;
	m_Wear = true;
	m_Use = false;
	m_Tile = t;
	m_Type = 6;
	m_Collide = false;
	m_DrawPass = 1;
	m_WearType = w;
	m_Armor = a/2;
	m_Shown = true;
	m_Tile = 13;
	m_Amount = 1;
};
CArmor::~CArmor()
{
};

CItem *CArmor::SpawnSelf(int x,int y)
{
	CArmor *o;
	CEngine *e;
	int i;
	e = (CEngine *)GetEngine();
	o = new CArmor(m_Name,m_WearType,m_Tile,m_Armor);
	o->m_X = x;
	o->m_Y = y;
	o->m_Collide = m_Collide;
	o->m_Shown = m_Shown;
	o->m_Clear = m_Clear;
	o->m_Type = m_Type;
	o->m_MasterNum = -1;
	o->m_Amount = m_Amount;
	for(i=0;i<e->m_Game.m_MasterObjects.GetLength();i++)
		if(((CItem *)e->m_Game.m_MasterObjects.Get(i))==this)
			o->m_MasterNum = i;
	strncpy(o->m_Name,m_Name,255);
	e->m_Room->m_Objects.Add(o);

	return o;
};

void CArmor::Wear()
{
	CEngine *e;
	CPlayer *p;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	p->m_Armor+=m_Armor;
};
void CArmor::TakeOff()
{
	CEngine *e;
	CPlayer *p;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	p->m_Armor-=m_Armor;
	if(p->m_Armor<0)
		p->m_Armor=0;
};

CWeapon::CWeapon(char *n,int w,int t,int min,int max)
{
	strncpy(m_Name,n,255);
	m_Eat = false;
	m_Wear = true;
	m_Use = false;
	m_Tile = t;
	m_Type = 6;
	m_Collide = false;
	m_DrawPass = 1;
	m_WearType = w;
	m_Shown = true;
	m_Tile = 13;
	m_MinDamage = min;
	m_MaxDamage = max;
	m_Amount = 1;
};
CWeapon::CWeapon(char *n,int w,int t,int l,float min,float max)
{
	float points,total;
	strncpy(m_Name,n,255);
	m_Eat = false;
	m_Wear = true;
	m_Use = false;
	m_Tile = t;
	m_Type = 6;
	m_Collide = false;
	m_DrawPass = 1;
	m_WearType = w;
	m_Shown = true;
	m_Tile = 13;
	m_Amount = 1;
	points = l;
	total = min+max;
	if(total!=1.0)
	{
		min/=total;
		max/=total;
	};
	m_MinDamage = 1+(points*min);
	m_MaxDamage = 8+(points*max);
	
};
CWeapon::~CWeapon()
{
};

CItem *CWeapon::SpawnSelf(int x,int y)
{
	CWeapon *o;
	CEngine *e;
	int i;
	e = (CEngine *)GetEngine();
	o = new CWeapon(m_Name,m_WearType,m_Tile,m_MinDamage,m_MaxDamage);
	o->m_X = x;
	o->m_Y = y;
	o->m_Collide = m_Collide;
	o->m_Shown = m_Shown;
	o->m_Clear = m_Clear;
	o->m_Type = m_Type;
	o->m_Tile = m_Tile;
	strncpy(o->m_Name,m_Name,255);
	o->m_MasterNum = -1;
	o->m_Amount = m_Amount;
	for(i=0;i<e->m_Game.m_MasterObjects.GetLength();i++)
		if(((CItem *)e->m_Game.m_MasterObjects.Get(i))==this)
			o->m_MasterNum = i;
	e->m_Room->m_Objects.Add(o);
	return o;
};

void CWeapon::Wear()
{
	CEngine *e;
	CPlayer *p;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	p->m_Damage+=m_MinDamage;
	p->m_MaxDamage+=m_MaxDamage;
};
void CWeapon::TakeOff()
{
	CEngine *e;
	CPlayer *p;
	e = (CEngine *)GetEngine();
	p = (CPlayer *)e->m_Game.GetPlayer();
	p->m_Damage-=m_MinDamage;
	p->m_MaxDamage-=m_MaxDamage;
	if(p->m_Damage<0)
		p->m_Damage=0;
	if(p->m_MaxDamage<p->m_Damage-1)
		p->m_MaxDamage=p->m_Damage+1;
};

CLaundry::CLaundry()
{
	strncpy(m_Name,"+Laundry+",254);
	m_Type = 6;
	m_Collide = false;
	m_DrawPass = 1;
	m_WearType = 0;
	m_FoodAmount = 0;
	m_FoodType = false;
	
	m_Wear = false;
	m_Use = true;
	m_Eat = false;
	m_Tile = 13;
	m_Clear = true;
	m_X = 1;
	m_Y = 1;
	m_Amount = 1;
	m_MasterNum = -1;
};
CLaundry::~CLaundry()
{
};
void CLaundry::Use()
{
	CEngine *e;
	e = (CEngine *)GetEngine();
	mvprintw(0,0,"You win! No, really.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
	getch();
	getch();
	getch();
	getch();
	e->m_On = false;
};